/**
 * @file port.h
 * @author your name (you@domain.com)
 * @brief 
 * @version 0.1
 * @date 2022-07-14
 * 
 * @copyright Copyright (c) 2022
 * 
 */

#ifndef __PORT_H
#define __PORT_H

#include "k2os_config.h"


typedef unsigned char           u8_t;
typedef signed char             s8_t;
typedef unsigned short          u16_t;
typedef signed short            s16_t;
typedef unsigned int            u32_t;
typedef signed int              s32_t;
typedef unsigned long long      u64_t;
typedef signed long long        s64_t;
typedef unsigned int            os_stk_t;
typedef unsigned int            os_size_t;
typedef unsigned int            os_cpu_psr_t;


#undef NULL
#define NULL    0





/**
 ******************************************************************************************
 *                          interrupt disable/enable macro
 ******************************************************************************************
 */
u16_t port_cpu_xpsr_save(void);
void port_cpu_xpsr_restore(u16_t new_value);


#define os_enter_critical()           {cpu_psr = port_cpu_xpsr_save();}
#define os_exit_critical()            {port_cpu_xpsr_restore(cpu_psr);}


os_stk_t *port_task_stack_init(void (*task)(void *arg), 
                            void *arg, 
                            os_stk_t *stack);
void port_set_PendSV_Handler_lowest_priority(void);

void port_SVC_Handler(void);

void port_PendSV_Handler(void);

void port_start_first_task(void);

void port_Systick_init(void);

void port_trigger_PendSV_Handler(void);

void port_SysTick_Handler(void);


/**
 *************************************************************************
 *                      port for Handler 
 ************************************************************************* 
 */
#define port_PendSV_Handler     PendSV_Handler
#define port_SysTick_Handler    SysTick_Handler
#define port_SVC_Handler				SVC_Handler










#endif
